package com.zc.trendsDispatch.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.trendsDispatch.domain.ChargeStationCollection;
import com.zc.trendsDispatch.service.IChargeStationCollectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 场站历史功率数据Controller
 * 
 * @author ruoyi
 * @date 2024-05-10
 */
@RestController
@RequestMapping("/trendsDispatch/collection")
public class ChargeStationCollectionController extends BaseController
{
    @Autowired
    private IChargeStationCollectionService chargeStationCollectionService;

    /**
     * 查询场站历史功率数据列表
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:collection:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChargeStationCollection chargeStationCollection)
    {
        startPage();
        List<ChargeStationCollection> list = chargeStationCollectionService.selectChargeStationCollectionList(chargeStationCollection);
        return getDataTable(list);
    }

    /**
     * 导出场站历史功率数据列表
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:collection:export')")
    @Log(title = "场站历史功率数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChargeStationCollection chargeStationCollection)
    {
        List<ChargeStationCollection> list = chargeStationCollectionService.selectChargeStationCollectionList(chargeStationCollection);
        ExcelUtil<ChargeStationCollection> util = new ExcelUtil<>(ChargeStationCollection.class);
        util.exportExcel(response, list, "场站历史功率数据数据");
    }

    /**
     * 获取场站历史功率数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:collection:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(chargeStationCollectionService.selectChargeStationCollectionById(id));
    }

    /**
     * 新增场站历史功率数据
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:collection:add')")
    @Log(title = "场站历史功率数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeStationCollection chargeStationCollection)
    {
        return toAjax(chargeStationCollectionService.insertChargeStationCollection(chargeStationCollection));
    }

    /**
     * 修改场站历史功率数据
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:collection:edit')")
    @Log(title = "场站历史功率数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeStationCollection chargeStationCollection)
    {
        return toAjax(chargeStationCollectionService.updateChargeStationCollection(chargeStationCollection));
    }

    /**
     * 删除场站历史功率数据
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:collection:remove')")
    @Log(title = "场站历史功率数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(chargeStationCollectionService.deleteChargeStationCollectionByIds(ids));
    }
}
